<template>
  <div>
    <div class="page_vue"  v-if="!isShowFolderDetail">
      <div class="page_header">
        <div class="hearder_search_img">
          <!-- <img src="./../../../../assets/images/home/search5.jpg" /> -->
        </div>
        <div class="hearder_search">
          <SearchHeader pageType="enterprise" :rowData="rowData" />
        </div>
      </div>

      <div class="page_body">
        <div class="item_box item_box_bg">
          <LableRef :rowData="rowData" />
        </div>

        <div class="item_box_right">
          <div class="item_box_1 item_box_bg">
            <Notice :rowData="rowData" />
          </div>
          <div class="item_box_2 item_box_bg">
            <doorFolder :rowData="rowData" @portalLookClick="portalLookClick" />
          </div>
        </div>
      </div>
    </div>
    <!-- 部门文件夹详情 -->
    <div v-if="isShowFolderDetail">
      <div class="pageBox">
        <div class="bodyBox01" style="">
          <div class="titleBox">
            <el-page-header @back="goBack" :content="dataObj.realName"> </el-page-header>
          </div>
          <el-empty v-if="dataList.length == 0" description="暂无文件夹" :image-size="120"></el-empty>
          <div v-else class="bodyBox">
            <el-card class="card_box" v-for="(item, index) in dataList" :key="index" shadow="hover">
              <template #header>
                <div class="clearfix">
                  <span class="title">{{ item.realName }}</span>
                  <el-button style="float: right; padding: 3px 0; color: #fff" type="text " @click="apiUnifiedCollectionGetParentTreeNodeAll(item)">
                    更多
                    <i class="el-icon-s-unfold"></i>
                  </el-button>
                </div>
              </template>
              <div v-if="!item.childrenList">
                <el-empty description="暂无数据" :image-size="120"></el-empty>
              </div>
              <div v-else>
                <div
                  v-for="(items, indexs) in item.childrenList"
                  :key="indexs"
                  @click="apiUnifiedCollectionGetParentTreeNodeAll(items)"
                  class="text item backgrounds"
                >
                  <div class="item_item">
                    <el-tooltip :content="`${items.realName}${items.suffix ? '.' + items.suffix : ''}`">
                      <span class="item_title">
                        <svg-icon :icon-class="selectSvgIcons(items)" style="font-size: 26px; vertical-align: middle; margin-right: 6px"></svg-icon>
                        {{ items.realName }}{{ items.suffix ? '.' + items.suffix : '' }}
                      </span>
                    </el-tooltip>
                    <span class="item_times1">{{ items.createTime }}</span>
                  </div>
                </div>
              </div>
            </el-card>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
import SearchHeader from './component/enterpriseDoor/search-header.vue'; //搜索
import LableRef from './component/enterpriseDoor/label.vue'; //标签
import Notice from './component/enterpriseDoor/notice.vue'; // 公告
import doorFolder from './component/enterpriseDoor/doorFolder.vue'; // 部门文件夹
import { useEnterpriseDocStore } from '@/store/modules/enterpriseDoc';
const docStore = useEnterpriseDocStore();
const rowData: any = ref(docStore.row); // 获取父组件传递过来的数据
import { ApiPerRecentlyViewed } from '@/api/personDoc/personDocApi';

const RecentViewList = ref([]);
////////////////////////////////////////// 部门文件夹详情  /////////////
const dataList = ref<any[]>([]); // 部门文件夹列表
const dataObj = ref<any>({}); // 部门文件夹详情
const isShowFolderDetail = ref(false); // 是否显示部门文件夹详情
// 返回
const goBack = () => {
  isShowFolderDetail.value = false;
};
// 跳转到文件列表
const apiUnifiedCollectionGetParentTreeNodeAll = (row: any) => {
  proxy.$router.push({ path: '/newUi/enterprises/enterpriseDoc' });
};
const selectSvgIcons = (v: any) => {
  return proxy.$yuUtils.selectSvgIcon(v);
};
// 获取最近查看文件
const portalLookClick = (row: any) => {
  dataObj.value = row;
  dataList.value = row.childrenList.filter((item) => item.type == "folder");
  isShowFolderDetail.value = true;
}
const getRecentView = () => {
  let oParam = {
    page: 0,
    size: 30,
    libraryType: 'personal'
  };
  ApiPerRecentlyViewed(oParam).then((res) => {
    console.log(res, '最近查看文件');

    RecentViewList.value = res.data.rows;
  });
};

onMounted(() => {
  // getRecentView();
});
</script>

<style scoped lang="scss">
.page_vue {
  // background-image: linear-gradient(to bottom, #f0f6ff, #ffffff);
  // background-image: linear-gradient(to bottom, #c3eae5, #ffffff);
  // background-color: #f5f5f5;
  height: calc(100vh - 52px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.page_header {
  // background-color: #ffffff;
  width: 100%;
  height: 200px;
  overflow: hidden;
  // background-image: url('./../../../../assets/images/home/search5.jpg');
  // background-color: #f0f6ff;
  background-image: linear-gradient(180deg, #ccebee, #fff);

  // position: relative;
  // background: #f5f5f5;
  // background-image: linear-gradient(90deg, transparent 50px, #ffb4b8 50px, #ffb4b8 52px, transparent 52px),
  //   linear-gradient(#e1e1e1 0.1em, transparent 0.1em);
  // background-size: 100% 30px;
  .hearder_search_img {
    position: absolute;
    z-index: 0;
    right: 0;
    img {
      width: 100%;
    }
  }
  .hearder_search {
    width: 600px;
    margin: 0 auto;
    padding: 70px 0 0px;
  }
}
.page_body {
  width: 100%;
  overflow-x: auto;
  flex: 1;
  // display: grid;
  // grid-template-columns: repeat(2, 1fr);
  padding: 20px 80px;
  display: flex;
}
.item_box {
  // flex: 1;
  min-width: 400px;
  border-radius: 16px;
  // padding: 16px;
  position: relative; //用于表格自适应宽度
}
.item_box_bg {
  background-color: #ffffff;
  box-shadow: 0px 0px 6px rgba(0, 0, 0, 0.1);
  // background-image: linear-gradient(to bottom, #ebf1fc, #ffffff) !important;
}
.item_box_right {
  flex: 1;
  border-radius: 16px;
  margin-left: 30px;
}
.item_box_1 {
  padding: 16px;
  border-radius: 16px;
}
.item_box_2 {
  padding: 16px;
  border-radius: 16px;
  margin-top: 30px;
}
@mixin textOverflow($clamp) {
  text-overflow: ellipsis;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: $clamp; //元素几行显示
  -webkit-box-orient: vertical;
}
.pageBox {
  height: calc(100vh - 50px);
  overflow-y: auto;
  padding: 40px;
}
.bodyBox01 {
  margin: 0 auto;
  width: 100%;
}
.bodyBox {
  width: 100%;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 30px;
  .card_box {
    .text {
      font-size: 14px;
    }
    .textColor {
      color: #fff;
    }
    .item {
      padding: 8px 0;
    }
    .title {
      color: #fff;
    }
    .title:hover {
      cursor: pointer;
    }
    .item_item {
      display: flex;
      justify-content: space-between;
      align-content: center;
      .item_title {
        @include textOverflow(1);
        flex: 1;
      }
      .item_times1 {
        width: 140px;
      }
    }
    .item_item:hover {
      cursor: pointer;
      color: #36a3f7;
    }
  }
}
.card_box ::v-deep .el-card__header {
  padding: 10px 20px;
  font-weight: bold;
  color: #fff;
  background: #ffbd60; /* fallback for old browsers */
  background: -webkit-linear-gradient(to right, #ff8623, #ffbd60); /* Chrome 10-25, Safari 5.1-6 */
  background: linear-gradient(to right, #ff8623, #ffbd60); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
.backgrounds {
}
.titleBox {
  ::v-deep .el-page-header__left {
    &:hover {
      color: #36a3f7;
    }
  }
  // ::v-deep .el-page-header__content{
  //   color: #ff8623;
  // }
}
</style>
